package com.yuanluludev.app.activity

import android.view.View
import com.yuanluludev.app.R
import com.yuanluludev.app.databinding.ActivityImageDemoBinding
import com.yuanluludev.app.vm.ImageViewModel
import com.yuanluludev.imageloader.glide.GlideManager
import com.yuanluludev.lib_aop.Log
import com.yuanluludev.lib_aop.SingleClick
import com.yuanluludev.lib_base.base.BaseVmWithDBActivity
import com.yuanluludev.lib_utils.util.LogUtils
import com.yuanluludev.pgy.Pgy
import kotlinx.android.synthetic.main.activity_image_demo.*

class ImageActivity : BaseVmWithDBActivity<ImageViewModel, ActivityImageDemoBinding>() {

    companion object {
        const val IMAGE_URL =
            "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbkimg.cdn.bcebos.com%2Fpic%2Fc8ea15ce36d3d539b0847c9a3487e950352ab029&refer=http%3A%2F%2Fbkimg.cdn.bcebos.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1670469498&t=8a5c5f943451612b2d9aaa1e16242025"
    }

    override fun initEvents() {
        GlideManager.load(this, IMAGE_URL, ivNormalImage)
        GlideManager.loadRound(this, IMAGE_URL, 10, ivRoundImage)
        GlideManager.loadCircle(this, IMAGE_URL, ivCircleImage)
        setOnClickListener(R.id.ivNormalImage, R.id.ivRoundImage, R.id.btnClick)
    }

    //@Permissions(value = [Manifest.permission.CAMERA], isShowGuideDialog = true)
    @Log
    fun onSS() {
        LogUtils.e("PermissionsAspect", "===============check成功了 =============")
    }

    @SingleClick
    override fun onClick(view: View) {
        if (view.id == R.id.ivNormalImage) {
            LogUtils.e("AppLog", "=============== 1 被点击了=============")
        } else if (view.id == R.id.btnClick) {
           Pgy.checkVersionUpdate(this,true)
        } else if (view.id == R.id.ivRoundImage) {
            LogUtils.e("AppLog", "=============== 3 被点击了=============")
        }
    }

    override fun getLayoutResId(): Int {
        return R.layout.activity_image_demo
    }

    override fun viewModelClass(): Class<ImageViewModel> {
        return ImageViewModel::class.java
    }

}